﻿using UnityEngine;
using FairyGUI;


public class NoticeItem : GComponent
{
    GTextField lbl_title;
    GImage sp_bg;
    GTextField lbl_content;
    public int mIndex = 0;

    public override void ConstructFromXML(FairyGUI.Utils.XML xml)
    {
        base.ConstructFromXML(xml);
        lbl_title = this.GetChild("lbl_title").asCom.GetChild("lbl_tt_4_2").asTextField;
        sp_bg = (GImage)this.GetChild("sp_bg");
        lbl_content = this.GetChild("lbl_content").asCom.GetChild("lbl_ct_1").asTextField;
    }

    public void SetIndex(int value)
    {
        mIndex = value;
    }

    public void SetTitle(string value)
    {
        lbl_title.text = value;
    }

    public void SetContent(string value)
    {
        lbl_content.text = value;
    }

    public void SetBgSize()
    {
        sp_bg.size = new UnityEngine.Vector2(sp_bg.size.x, lbl_content.height + 60);
    }

    public float GetItemHeight()
    {
        return sp_bg.size.y;
    }

    public float GetItemWidth()
    {
        return sp_bg.size.x;
    }
}
